//app.js
App({
  onLaunch: function () {
    wx.cloud.init({
      traceUser: true,

  })
    wx.login({
      //获取code
      success: function (res) {
        var code = res.code; //返回code
        // console.log(code,"------------");
        var appId = 'wxe28a7d9f5c72e6ba';
        var secret = 'e6eecdc944562ec81a75bb49690cb903';
        wx.request({
          url: 'https://api.weixin.qq.com/sns/jscode2session?appid=' + appId + '&secret=' + secret + '&js_code=' + code + '&grant_type=authorization_code',
          data: {},
          header: {
            'content-type': 'json'
          },
          // success: function (res) {
            // var openid = res.data.openid //返回openid
            // console.log(res);
            // console.log('openid为' + openid);
          // }
        })
      }
    })

    this.globalData = {}
  }
})
